package k2_oop.p9_collection.demo08;

import java.util.ArrayList;
import java.util.Collections;

public class UnionLotto {

    //存储22个数字的集合
    private static ArrayList<String> nums = new ArrayList<>();

    //在匿名块中初始化22个数字
    static{
        //初始化22个数字的集合
        for (int i = 1; i <=22 ; i++) {
            nums.add(String.format("%02d",i));
        }
    }

    /**
     * 抽取5个数字
     * @return
     */
    public static String chooseNum(){

        //打乱顺序
        Collections.shuffle(nums);

        //返回打乱顺序后的前5个数字
        return nums.subList(0,5).toString();
    }

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            System.out.println(UnionLotto.chooseNum());
        }
    }
}
